package jia.core;

import javax.vecmath.Vector2d;

/**
 * Encapsulates a Space and Facing, assigning a name for use as an entry point
 * in a module.
 * <p/>
 * "default" is a special case, and is used by the GameStateManager to specify
 * the player entrypoint when modules are changed without requesting a specific
 * entry point.
 *
 * @author Alec Lanter
 */
public class EntryPoint {
    public static final String DEFAULT_NAME = "default";
    
    protected long id;
    private String name = DEFAULT_NAME;
    private Vector2d entryPosition = new Vector2d(1, 1);
    private int entryFacing = Compass.NORTH_VAL;
    
    /**
     * @return Returns the entryFacing.
     */
    public Compass getEntryFacing() {
        return Compass.forDirectionalValue(entryFacing);
    }
    
    /**
     * @param entryFacing The entryFacing to set.
     */
    public void setEntryFacing(Compass entryFacing) {
        this.entryFacing = entryFacing.getDirectionalValue();
    }
    
    /**
     * @return Returns the name.
     */
    public String getName() {
        return name;
    }
    
    /**
     * @param name The name to set.
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object o) {
        if (o instanceof EntryPoint) {
            return name.equalsIgnoreCase(((EntryPoint) o).name);
        } else {
            return false;
        }
    }
    
    /**
     * @return Returns the entryPosition.
     */
    public Vector2d getEntryPosition() {
        return entryPosition;
    }
    
    /**
     * @param entryPosition The entryPosition to set.
     */
    public void setEntryPosition(Vector2d entryPosition) {
        this.entryPosition = entryPosition;
    }
    
    /**
     * @param x
     * @param y
     */
    public void setEntryPosition(int x, int y) {
        entryPosition = new Vector2d(x, y);
    }
}
